﻿<?php

use yii\helpers\Html;
use yii\widgets\ActiveForm;
use yii\web\View;
use backend\models\service\AdminService as Admin;
use backend\models\service\Chapter;
use yii\helpers\Url;
use backend\widgets\GridView;
use backend\models\service\CateService as Cate;
?>

<div id = "unque" name ="<?php echo $id?>">
    <div class="TopUl_Atable_nv">
        <table class="Atable mytable TopUl_Atable_nvone">
            <tr>
<!--                <td>
                    <input class="styled Checkbox Checkboxnv checkbox1" id="nv"/>
                </td>-->
                <td colspan="2">
                    女频
                </td>
            </tr>
            <?php foreach ($nv_datas as $v): ?>
                <tr class="TR">
                    <td>
                        <input name="r" class="styled Checkbox Checkboxnv checkbox1" type="radio" value="<?php echo $v['cate_id']; ?>"/>
                    </td>
                    <td>
                        <?php echo $v['cate_name']; ?>
                    </td>
                </tr>
            <?php endforeach; ?>
        </table>
    </div>
    <div class="TopUl_Atable_nan">
        <table class="Atable mytable TopUl_Atable_nvone nan">
            <tr>
                <td colspan="2">
                    男频
                </td>
            </tr>
            <?php foreach ($nan_datas as $v): ?>
                <tr class="TR">
                    <td>
                        <input name="r" class="styled Checkbox Checkboxnan checkbox1" type="radio" value="<?php echo $v['cate_id']; ?>"/>
                    </td>
                    <td>
                        <?php echo $v['cate_name']; ?>
                    </td>
                </tr>
            <?php endforeach; ?>
        </table>
    </div>
    <p >
        <?= Html::submitButton('保存创建', ['class' => 'sub btn btn-primary', 'name' => 'submit-button']) ?>
    </p>
    <hr>
</div>

<script>
    $(function() {
        $(".sub").click(function(){
            var cid = $('input:radio:checked').val();
            if(zz_keys == ''){
                alert('请选择需要操作的小说');
                return false;
            }
            var id = zz_keys;
            $.ajax({
                url: "/novel/post-up-cate-batch",
                type: "POST",
                dataType: "json",
                data: {'cid':cid,'id':id},
                success: function(Data) {
                    if(Data.status == 0){
                        alert('保存成功');
                    }else{
                        alert('保存失败');
                    }
                    location.href="/novel/index"
                    zz_keys = ''
                },
                error: function() {
                    alert('网络错误！');
                    location.href="/novel/index"
                    zz_keys = ''
                }
            });
         });
    })

</script>
